<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>家庭辅导系统</title>
    <!-- Bootstrap core CSS -->
    <link href="<?php echo base_url('application/views/css/bootstrap.css'); ?>" rel="stylesheet">
    <link href="<?php echo base_url('application/views/css/main.css'); ?>" rel="stylesheet">
    <script src="<?php echo base_url('application/views/js/jquery.min.js'); ?>"></script>
    <script src="<?php echo base_url('application/views/js/bootstrap.js'); ?>"></script>
    <!-- 引入layer插件，实现增强web弹窗和层效果 -->
    <script src="<?php echo base_url('application/views/js/layer/layer.js'); ?>"></script>
    <script>
// 弹出登录模拟窗口
function displayLoginView() {
    layer.open({
        type: 2,
        title: '登录窗口',
        shadeClose: true,
        shade: 0.8,
        closeBtn: 1,
        area: ['530px', '360px'],
        content: '<?php echo site_url("user/loginForm") ?>',
        end: function() {
            location.href = '<?php echo site_url("admin/admin/index") ?>';
        }
    });
}

// 弹出注册模拟窗口
function displayRegView() {
    layer.open({
        type: 2,
        title: '注册窗口',
        shadeClose: true,
        shade: 0.8,
        closeBtn: 1,
        area: ['530px', '360px'],
        content: '<?php echo site_url("user/regForm") ?>' //iframe的url
    });
}

$(document).ready(function() {

    // 设定登录功能
    $("li#loginlink a").click(function() {
        displayLoginView();
    });

    // 设定注册链接功能
    $("li#reglink a").click(function() {
        displayRegView();
    });

    // 设定注册链接功能
    $("li#logout a").click(function() {
        $.post('<?php echo site_url("User/logout") ?>', function(data, textStatus, xhr) {
            layer.msg('已退出',function(){
                window.location.reload();
            });

        });
        // console.log(symbol);
        // displayGrid(scode);
        // 阻止原有事件的默认行为。
        return false;
    });

});
</script>
</head>

<body role="document">
    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">陪伴成长</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">首页</a></li>
                    <li><a href="<?php echo site_url('/learn'); ?>">开始学习</a></li>
                    <li><a href="#contact">Contact</a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">系统设置<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="#">设置</a></li>
                            <li role="separator" class="divider"></li>
                            <li class="dropdown-header">Nav header</li>
                            <li><a href="#">Separated link</a></li>
                            <li><a href="#">One more separated link</a></li>
                        </ul>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li id="reglink"><a href="javascript:;">注册</a></li>
                    <?php if(!isset($this->session->userdata['email'])): ?>
                        <li id="loginlink"><a href="javascript:;">登录</a></li>
                        <?php else: ?>
                            <li id="logout"><a href="<?php echo site_url('/user/logout/'); ?>"><?php echo $this->session->userdata['email']; ?></a></li>
                            <?php endif; ?>
                </ul>
            </div>
            <!--/.nav-collapse -->
        </div>
    </nav>
